<?php

interface iFacebookAuthDTO {}

class dtoFacebookAuth implements iFacebookAuthDTO
{
	public $oauth_token         = NULL;

	public $access_token        = FALSE;

	public $user_id             = NULL;
	public $username            = NULL;
	public $name                = NULL;
	public $timezone            = NULL;


	const SESSION_FB_AUTH_DTO   = 'dto_facebook_auth';

	public static function factory(dtoFacebookAuth $paramFbAuthDTO = NULL)
	{
		static $fbAuthDTO = NULL;

		// save
		if ($paramFbAuthDTO)
		{
			$_SESSION[self::SESSION_FB_AUTH_DTO] = serialize($paramFbAuthDTO);
			return;
		}

		// get
		if ($fbAuthDTO)
		{
			return $fbAuthDTO;
		}
		else if (array_key_exists(self::SESSION_FB_AUTH_DTO, $_SESSION))
		{
			$fbAuthDTO = unserialize($_SESSION[self::SESSION_FB_AUTH_DTO]);

			if ($fbAuthDTO instanceof iFacebookAuthDTO)
				return $fbAuthDTO;
		}

		return $fbAuthDTO = new dtoFacebookAuth();
	}
}

# EOF
